package 高考志愿填报系统1;
import java.util.ArrayList;
import java.util.List;

public class Student {
    public static final String volunteer = null;
	private String id;
    private String name;
    private List<Volunteer> volunteers;

    // 构造函数，初始化学生信息和志愿列表
    public Student(String id, String name) {
        this.setId(id);
        this.name = name;
        this.setVolunteers(new ArrayList<>());
    }

    // 添加志愿的方法，如果志愿数未达到上限，则添加
    public void addVolunteer(Volunteer volunteer) {
        if (getVolunteers().size() < 30) {
            getVolunteers().add(volunteer);
        } else {
            System.out.println("志愿数量已达上限");
        }
    }

    // 调整志愿顺序的方法，如果索引有效，则调整
    public void adjustVolunteerOrder(int oldIndex, int newIndex) {
        if (oldIndex >= 0 && oldIndex < getVolunteers().size() && newIndex >= 0 && newIndex <= getVolunteers().size()) {
            Volunteer volunteer = getVolunteers().remove(oldIndex);
            getVolunteers().add(newIndex, volunteer);
        } else {
            System.out.println("索引超出范围");
        }
    }

    // 打印学生所有志愿的方法
    public void printVolunteers() {
        System.out.println("学生：" + name + " 的志愿列表：");
        for (int i = 0; i < getVolunteers().size(); i++) {
            System.out.println((i + 1) + ". " + getVolunteers().get(i).toString());
        }
    }

	public List<Volunteer> getVolunteers() {
		return volunteers;
	}

	public void setVolunteers(List<Volunteer> volunteers) {
		this.volunteers = volunteers;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
}
